package com.statistics.controller;

import com.statistics.config.ExportExcelUtil;
import com.statistics.entity.StatisticsDto;
import com.statistics.entity.SupplementDto;
import com.statistics.service.StatisticsService;
import com.statistics.service.supplementary.SupplementaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * @author hewei
 * @date 2022/4/29 17:03
 * @Description
 */
@RestController
@RequestMapping("/api/v1/common/auth/")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    @Autowired
    private SupplementaryService supplementaryService;


    @PostMapping("/import")
    public void getYhList(MultipartFile yhFile, MultipartFile importFile){
        Map<String, List<StatisticsDto>> statistics = statisticsService.statistics(yhFile, importFile);
        String[] titles = {"处理人","客户姓名","证件号码","贷款账号","处理时间","催收方式","外呼对象","联络方式","地址类型","详细地址","联络结果","催收结果","特殊标签","催收记录"};
        ExportExcelUtil.ExportExcel(statistics,titles);
    }


    @PostMapping("/supplementary")
    public void supplementary(MultipartFile yhFile, MultipartFile importFile) throws ExecutionException, InterruptedException {
        Map<String, List<SupplementDto>> statistics = supplementaryService.supplementary(yhFile, importFile);
        String[] titles = {"姓名","卡号","证件号","关系","电话/地址","联络结果","催收结果","催收时间","催收措施","催收内容","催收状态"};
        ExportExcelUtil.ExportExcels(statistics,titles);
    }
}
